﻿using Modules.System.Role;
using PmSoft;

namespace Modules.System.Menu
{
    public static class MenuExceptions
    {
        public static IEnumerable<string> GetRoleCodes(this SysMenu menu)
        {
            var roles = menu.GetRoles();
            return roles.Select(x => x.Code);
        }

        public static IEnumerable<SysRole> GetRoles(this SysMenu menu)
        {
            var roleService = ServiceAccessor.GetService<RoleService>();
            return roleService.GetRolesByMenuId(menu.MenuId);
        }
    }
}